import {Event} from "socket.io/dist/socket";
import { isType } from "../src/utils/utils";

export function middlewares (app, io) {
  /*if (!socket.setInviteUser) {
    socket.setInviteUser = (members) => {
      if (!socket.inviteUsers) {
        socket.inviteUsers = new Map
      }

      if (isType(members, 'array')) {
        members.forEach(member => {
          socket.inviteUsers.set(member.userId, member)
        })
      } else {
        socket.inviteUsers.set(members.userId, members)
      }
    }
  }*/

  /*if (!socket.errorMsg) {
    socket.errorMsg = function errorMsg(type, message, data) {
      console.error(`error:${type} =>`, message)
      return {
        ...data,
        status: 'error',
        resolve: `[response]:${type}`,
        message
      }
    }
  }*/

  /*if (!socket.timeoutMsg) {
    socket.timeoutMsg = function timeoutMsg(type, message, data) {
      console.warn(`timeout:${type} =>`, message)
      return {
        ...data,
        status: 'timeout',
        resolve: `[response]:${type}`,
        message,
      }
    }
  }*/

  /*if (!socket.okMsg) {
    socket.okMsg = function okMsg(type, data) {
      console.log(`ok:${type} =>`)
      return {
        ...data,
        status: 'ok',
        resolve: `[response]:${type}`,
      }
    }
  }*/


  /*socket.use((event: Event, next: (err?: Error) => void) => {
    // const [name, params] = event

    // console.log('这是一个：setInviteUser ', event, name, params)

    next()
  })*/
}
